home *** CD-ROM | disk | FTP | other *** search
/ Mac Magazin/MacEasy 96 / maccd 96.iso / utilities / Mac OS X / DoubleCommand 1.3 / Source / DoubleCommand.c < prev    next >
Encoding:
C/C++ Source or Header  |  2002-07-04  |  1.8 KB  |  77 lines

  1. /*
  2.  * Name: DoubleCommand.c
  3.  * Project: DoubleCommand
  4.  * Author: Michael Baltaks <mbaltaks@mac.com>
  5.  * Creation Date: 2002-4-26
  6.  * Last Modified: 2002-6-6
  7.  * Originally based on iJect by Christian Starkjohann <cs@obdev.at> 
  8.  * Tabsize: 4
  9.  * Copyright: GNU General Public License version 2.0
  10.  */
  11.  
  12. #include <mach/mach_types.h>
  13. #include <sys/systm.h>
  14. #include <sys/param.h>
  15. #include <sys/sysctl.h>
  16.  
  17. extern int MBHidInit(void);
  18. extern int MBHidExit(void);
  19.  
  20. /* the sysctl docs said to declare this */
  21. struct sysctl_oid_list sysctl__dc_children;
  22.  
  23. /* a variable in MBHIDHack.cpp for configuring this program */
  24. extern
  25. int dcConfig;
  26.  
  27. /* this is the function that handles getting and setting the config */
  28. static int
  29. dc_sysctl_config SYSCTL_HANDLER_ARGS
  30. {
  31.     int error = 0;
  32.     if (arg1)
  33.     {
  34.         error = SYSCTL_OUT(req, arg1, sizeof(int));
  35.     }
  36.     else
  37.     {
  38.         error = SYSCTL_OUT(req, &arg2, sizeof(int));
  39.     }
  40.     if (error || !req->newptr)
  41.     {
  42.         return (error);
  43.     }
  44.  
  45.     if (!arg1)
  46.     {
  47.         error = EPERM;
  48.     }
  49.     else
  50.     {
  51.         error = SYSCTL_IN(req, arg1, sizeof(int));
  52.     }
  53.     return (error);
  54. }
  55.  
  56. /* declare the new top level sysctl node "dc" */
  57. SYSCTL_NODE(, OID_AUTO, dc, CTLFLAG_RW, 0, "DoubleCommand");
  58.  
  59. /* declare a new child of our new node and a handler function */
  60. SYSCTL_PROC (_dc, OID_AUTO, config, CTLTYPE_INT|CTLFLAG_RW|CTLFLAG_ANYBODY, &dcConfig, 0, &dc_sysctl_config, "I", "Double Command Configuration");
  61.  
  62. /* kext init auto built by Project Builder */
  63. kern_return_t DoubleCommand_start (kmod_info_t * ki, void * d)
  64. {
  65.     sysctl_register_oid(&sysctl__dc);
  66.     sysctl_register_oid(&sysctl__dc_config);
  67.     return MBHidInit() == 0 ? KERN_SUCCESS : KERN_FAILURE;
  68. }
  69.  
  70. /* kext unload auto built by Project Builder */
  71. kern_return_t DoubleCommand_stop (kmod_info_t * ki, void * d)
  72. {
  73.     sysctl_unregister_oid(&sysctl__dc);
  74.     sysctl_unregister_oid(&sysctl__dc_config);
  75.     return MBHidExit() == 0 ? KERN_SUCCESS : KERN_FAILURE;
  76. }
  77.